#include<stdio.h>
#include <errno.h>
#include <signal.h>
#include <stdio.h>
#include <string.h>
#include <sys/resource.h>
#include <sys/time.h>
#include <sys/types.h>
#include <unistd.h>
#include <time.h> /* clock_gettime() */
#include <sys/mman.h> /* mlockall() */
#include <sched.h> /* sched_setscheduler() */
#include <sys/mman.h>
#include <pthread.h>
#include <math.h>
#define PI 3.1415926535898
#include"ecrt.h"

/****************************************************************************/

// EtherCAT
extern ec_master_t *master;
extern ec_master_state_t master_state;

extern ec_domain_t *domainServoInput ;
extern ec_domain_state_t domainServoInput_state ;
extern ec_domain_t *domainServoOutput ;
extern ec_domain_state_t domainServoOutput_state ;

extern uint8_t *domainOutput_pd ;
extern uint8_t *domainInput_pd ;

extern ec_slave_config_t *sc_cooldrive0 ;
extern ec_slave_config_state_t sc_cooldrive0_state;
extern ec_slave_config_t *sc_cooldrive1 ;
extern ec_slave_config_state_t sc_cooldrive1_state ;
/*************************************************************************/


void check_master_state(void);
void check_slave0_config_states(void);
void check_slave1_config_states(void);

void check_domainInput_state(void);
void check_domainOutput_state(void);

/****************************************************************************/

/** Task period in ns. */
#define PERIOD_NS   (4000000)

#define MAX_SAFE_STACK (8 * 1024) /* The maximum stack size which is
                                     guranteed safe to access without
                                     faulting */

/****************************************************************************/

/* Constants */
#define NSEC_PER_SEC (1000000000)
#define FREQUENCY (NSEC_PER_SEC / PERIOD_NS)

/****************************************************************************/







